package com.imooc.order.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.Arrays;

/**
 * @Name com.imooc.order.controller.HystrixController
 * @Description
 * @Author Elwyn
 * @Version 2020/3/19
 * @Copyright 上海云辰信息科技有限公司
 **/
@RestController

public class HystrixController {
	@GetMapping("/getProductListHys")
	@HystrixCommand(fallbackMethod = "fallback")
	public String getProductList() {
		RestTemplate restTemplate = new RestTemplate();
		return restTemplate.postForObject("http://127.0.0.1:8083/product/listForOrder", Arrays.asList("1"), String.class);
	}

	public String fallback() {
		return "请稍后再试";
	}
}
